package com.nondo.dean.saprfc.service;

import com.nondo.dean.saprfc.common.SapUtil;
import com.nondo.dean.saprfc.domain.ProductTypeBean;
import com.sap.conn.jco.JCoFunction;
import com.sap.conn.jco.JCoTable;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

/**
 * 　* @Description: 获取sap中的产品类型数据
 * 　* @param ${tags}
 * 　* @return ${return_type}
 * 　* @throws
 * 　* @author xiaofan
 * 　* @date 2018-03-2715:14
 */
@Service
public class CrmProdTypeService {

    /**
     * @param SAP_CLIENT
     * @return
     * @throws Exception
     * @Description
     */
    public ArrayList getProductType(String SAP_CLIENT) {

        ArrayList productList = new ArrayList();
        JCoFunction function = SapUtil.getFunction("", "Z_ND_OA_MATNR_A");
        SapUtil.executeFunction("", function);
        JCoTable v_table = function.getTableParameterList().getTable("EX_T023T");
        for (int i = 0; i < v_table.getNumRows(); i++) {

            String v_matkl = v_table.getString("MATKL"); //物料组
            String v_wgbez = v_table.getString("WGBEZ"); //物料名称

            ProductTypeBean productType = new ProductTypeBean(null, v_matkl, v_wgbez);
            productList.add(productType);

            v_table.nextRow();
        }
        return productList;
    }


}
